
import asyncio
import logging
from pathlib import Path
import json
from dataclasses import asdict
from datetime import datetime

from ..agenthub.dummy import DummyFlow
from .mock import get_agent_config

root_dir = Path(__file__).resolve().parent.parent.parent
logging.basicConfig(
    level=logging.INFO,
    format='%(asctime)s - %(name)s - %(levelname)s - %(filename)s:%(lineno)d - %(message)s')

# Configure logging
logger = logging.getLogger('tests.cli')
provider="openai"
question="列出mysql所有的database，并找出跟股票信息相关的表，列出表结构"

server_name="mysql-mcp"
"""
provider="ollama"
"""
if server_name == "postgres-mcp":
    provider="ollama"
    question="列出当前数据库所有用户可以操作的模式(Schema)?并列出所有模式中包含users表的详细信息"
async def main():
    if server_name == "postgres-mcp":
        mcp_server, agent_config=get_agent_config(mcp_server=server_name)
    else:
        mcp_server, agent_config=get_agent_config()
    
    shared = {
        "question": question, 
        "system_prompt": "simple.md",
        "context": {
            "agent":{
                "name": "dummy",
                "config": agent_config,
                "mcp_server": mcp_server,
            },
            "messages": [],
            "events": [],
        }
    }
    dummy_flow=DummyFlow(shared=shared)
    dummy_flow.create_flow()
    step=await dummy_flow.run()
    print(step)

"""
Usage:
  - python -m py.tests.cli
"""
if __name__ == "__main__":
    asyncio.run(main())
